package com.crm.sys.controller;

import java.io.File;
import java.io.FileInputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.crm.base.controller.BaseController;
import com.crm.customers.model.CustomerContacts;
import com.crm.customers.model.CustomerInfo;
import com.crm.customers.model.CustomerInfoTemp;
import com.crm.customers.service.CustomerContactsService;
import com.crm.customers.service.CustomerInfoTempService;
import com.crm.customers.service.CustomerService;
import com.crm.util.CommonUtil;

@Controller
public class ReadExcelController  extends BaseController {
	
	@Autowired
	private CustomerService customerService;
	
	@Autowired
	private CustomerContactsService customerContactsService;
	
	@Autowired
	private CustomerInfoTempService customerInfoTempService;
	
	
	
	//用于接收错误信息
	private static List<String> loglist = new ArrayList<String>();
	
	//用于记录姓名
	private static String name = "";
	
	/**
	 * 2017/7/28新增
	 * 传入excel然后将表中的内容存入临时表
	 * 根据电话号码绑定customer表
	 * 只有个人,没有企业
	 * */
	@RequestMapping(value="/systerm/upexcelastemp")
	public String readExcelAndSaveAsTemp(@RequestParam MultipartFile file,HttpServletResponse response,HttpServletRequest request,
			RedirectAttributes arrt){
		
		String url = "/customer/customertemplist";
		
		int allcount = 0;//总条数
		int successcount = 0;//成功的条数
		int wrongcount = 0;//失败的条数
		//将获取的文件存入服务器
		if (file != null) {
			//将文件上传至服务器
			String path=request.getSession().getServletContext().getRealPath("upload/excelfile/");
			//获取文件地址
			String webpath = saveUpTempFile(file, path);
			//读取文件并将文件内容保存到数据库
			try {
				if (webpath != null) {
					String filepath = path + File.separator + webpath;
					File excelFile = new File(filepath); //创建文件对象  
			        FileInputStream is = new FileInputStream(excelFile); //文件流  
			        Workbook workbook = WorkbookFactory.create(is); //这种方式 Excel 2003/2007/2010 都是可以处理的  
			        int sheetCount = workbook.getNumberOfSheets();  //Sheet的数量
			        //循环遍历每个sheet
			        for (int s = 0; s < sheetCount; s++) {
			        	Sheet sheet = workbook.getSheetAt(s);  
			            int rowCount = sheet.getPhysicalNumberOfRows(); //获取总行数
			            //便利每一行，因为第一行是标题，因为第一行是标题，所以不遍历
			            for (int r = 1; r < rowCount; r++) {
			            	//临时表对象
			            	CustomerInfoTemp cit = new CustomerInfoTemp();
			            	Row row = sheet.getRow(r);
			            	int cellCount = row.getPhysicalNumberOfCells(); //获取总列数 
			            	//遍历每一列
			            	//默认数据是符合规则的，设置这个而不直接break是为了获取一行中的所有错误
			            	boolean cellIsAllow = true;
			            	for (int c = 0; c < cellCount; c++) {
			            		Cell cell = row.getCell(c);
			            		if (tempDataIsAllow(cell, c, r)){
			            			String value ="";
				            		if(cell!=null){
			            				value =  getCellValue(cell); 
			            			}
				            		cit = saveTempInfo(cit, c, value);
			            		} else {
			            			//单元格内容没有通过验证
			            			cellIsAllow = false;
			            		}
			            	}
			            	if (cellIsAllow) {
			            		//将获取到的temp对象存入数据库
			            		cit.setType(0);
				            	customerInfoTempService.insertTempInfo(cit);
				            	//成功的数量+1
			            		successcount += 1;
			            	} else {
			            		//说明数据不合格失败的数量+1
			            		wrongcount += 1;
			            	}
			            	//总条数+1
			            	allcount += 1;
			            	name = "";
			            }
			        }
			        excelFile.delete();
				}
			} catch (Exception e) {
				e.printStackTrace(); 
			}
		}
		
		//向页面传递需要展示的信息
		StringBuffer successlog = new StringBuffer("资源导入完毕，共有资源"+ allcount +"条。导入成功" + successcount + "条，导入失败" + wrongcount + "条。<br/>");
		for (String s : loglist) {
			successlog.append(s + "<br/>");
		}
		arrt.addFlashAttribute("successlog", successlog.toString());
		
		//将list清空
		loglist = new ArrayList<String>();
		
		//页面跳转
		return "redirect:"+url;
	}
	
	
	
	
	
	/**
	 * 上传excel文件到指定文件夹，并读取内容，存入数据库
	 * */
	@RequestMapping(value="/systerm/uploadexcel")
	public String readExcelAndSave(@RequestParam MultipartFile file,Integer type,Integer state, HttpServletResponse response,HttpServletRequest request,
			RedirectAttributes arrt){
		
		int allcount = 0;//总条数
		int successcount = 0;//成功的条数
		int wrongcount = 0;//失败的条数
		
		//将获取的文件存入服务器
		if (file != null) {
			//将文件上传至服务器
			String path=request.getSession().getServletContext().getRealPath("upload/excelfile/");
			//获取文件地址
			String webpath = saveUpTempFile(file, path);
			//读取文件并将文件内容保存到数据库
			try {
				if (webpath != null) {
					String filepath = path + File.separator + webpath;
					File excelFile = new File(filepath); //创建文件对象  
			        FileInputStream is = new FileInputStream(excelFile); //文件流  
			        Workbook workbook = WorkbookFactory.create(is); //这种方式 Excel 2003/2007/2010 都是可以处理的  
			        int sheetCount = workbook.getNumberOfSheets();  //Sheet的数量
			        //循环遍历每个sheet
			        for (int s = 0; s < sheetCount; s++) {
			        	Sheet sheet = workbook.getSheetAt(s);  
			            int rowCount = sheet.getPhysicalNumberOfRows(); //获取总行数
			            //便利第一行,获取总列数
			            int cellCount = 0;
			            for (int r = 0; r < 1; r++) {
			            	Row row = sheet.getRow(r);
			            	cellCount = row.getPhysicalNumberOfCells(); //获取总列数
			            }
			            //便利每一行，因为第一行是标题，因为第一行是标题，所以不遍历
			            for (int r = 1; r < rowCount; r++) {
			            	CustomerInfo info = new CustomerInfo();
			            	info.setType(type);
			            	info.setState(state);
			            	Row row = sheet.getRow(r);
			            	//遍历每一列
			            	//默认数据是符合规则的，设置这个而不直接break是为了获取一行中的所有错误
			            	boolean cellIsAllow = true;
			            		for (int c = 0; c < cellCount; c++) {
				            		Cell cell = row.getCell(c);
				            		if (dataIsAllow(type, cell, c, r)){
				            			//单元格内容通过验证
				            			String value ="";
				            			if(cell!=null){
				            				value =  getCellValue(cell);
				            			}
				            			info = saveInfo(info, c,value);
				            		} else {
				            			//单元格内容没有通过验证
				            			cellIsAllow = false;
				            		}
				            	}
			            		//查看数据是否合格
				            	if (cellIsAllow) {
				            		//说明数据合格，存入数据库
				            		if(getLoginUser().getId().equals(1L)) {
				            			info.setState(4);
				            		}else {
				            			info.setUid(getLoginUser().getId());
				            		}
				            		
									/*
									 * if (info.getState() != 4) { //说明是存到私有库里 info.setUid(getLoginUser().getId());
									 * }
									 */
				            		if(info.getBoutique()==null) {
				            			info.setBoutique(0); //普通资源
				            		}else {
				            			info.setState(1); //精品资源资源 设置资源状态为 意向不明
				            		}
				            		customerService.saveCustomerInfo(info);
				            		//成功的数量+1
				            		successcount += 1;
				            	} else {
				            		//说明数据不合格失败的数量+1
				            		wrongcount += 1;
				            	}
				            	//总条数+1
				            	allcount += 1;
				            	name = "";
			            	}
			        }
			        excelFile.delete();
				}
			} catch (Exception e) {
				e.printStackTrace(); 
			}
		}
		
		//向页面传递需要展示的信息
		StringBuffer successlog = new StringBuffer("资源导入完毕，共有资源"+ allcount +"条。导入成功" + successcount + "条，导入失败" + wrongcount + "条。<br/>");
		for (String s : loglist) {
			successlog.append(s + "<br/>");
		}
		arrt.addFlashAttribute("successlog", successlog.toString());
		
		//将list清空
		loglist = new ArrayList<String>();
		
		//页面跳转
		String url = "/customer/entman/ty"+type;
		if (state!=null&&state==4) {
			url += "_st4";
		}
		return "redirect:"+url;
	}
	
	
	/**
	 * 取得文件名及文件后缀名 [0]为文件名  [1]为文件后缀
	 * @param fileName
	 * @return
	 */
	private static String[] splitFileName(String fileName){
		String fileAndExt[] ={fileName.substring(0,fileName.lastIndexOf(".")),
				fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase()};
		return fileAndExt;
	}
	
	/**
	 * 检测压缩包文件类型
	 * */
	private static boolean validateCompressFileType(String type) {
		boolean result = false;
		try{
	    	String[] typesStr = {"xls","xlsx"};
	    	for(String typeStr :typesStr){
	    		if(typeStr.equals(type)){
	    			result = true;
	    			break;
	    		}
	    	}
    	}catch(Exception e){
    	}
		return result;
	}
	
	/**
	 * 保存excel文件,并获得保存路径
	 * */
	private static String saveUpTempFile(MultipartFile file,  String path){
		String fileUrl = "";
		if(StringUtils.isEmpty(file.getOriginalFilename())){
			return  fileUrl;
	    }
		String[]  name= splitFileName(file.getOriginalFilename());
		boolean b = validateCompressFileType(name[1]);
		if(b){
	    	   try{
	    		   String pathAll = CommonUtil.getNewFileName()[0]+"."+name[1];
	    		   File tempFile = new File( path,pathAll); 
		           FileUtils.copyInputStreamToFile(file.getInputStream(),tempFile );  
		     	   return pathAll;
		     	}catch(Exception e){
		     		e.printStackTrace();
		     	} 
	    	}
		return fileUrl;
	}
	

	@SuppressWarnings("deprecation")
	private String getCellValue(Cell cell){
		
		
		
		String cellValue = null;
		if (cell!= null) {
			  SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");  
			  int cellType = cell.getCellType();  
              switch(cellType) {  
                  case Cell.CELL_TYPE_STRING: //文本  
                      cellValue = cell.getStringCellValue();  
                      break;  
                  case Cell.CELL_TYPE_NUMERIC: //数字、日期  
                      if(DateUtil.isCellDateFormatted(cell)) {  
                          cellValue = fmt.format(cell.getDateCellValue()); //日期型  
                      }  
                      else { 
                    	  DecimalFormat df = new DecimalFormat("#");
                          cellValue = df.format(cell.getNumericCellValue()); //数字
                      }
                      break;  
                  case Cell.CELL_TYPE_BOOLEAN: //布尔型  
                      cellValue = String.valueOf(cell.getBooleanCellValue());  
                      break;  
                  case Cell.CELL_TYPE_BLANK: //空白  
                      cellValue = cell.getStringCellValue().trim();  
                      break;  
                  case Cell.CELL_TYPE_ERROR: //错误  
                      cellValue = "";  
                      break;  
                  case Cell.CELL_TYPE_FORMULA: //公式  
                      cellValue = "";  
                      break;  
                  default:  
                      cellValue = "";  
              }
			
			//cellValue = cell.getStringCellValue();
		}
		return cellValue;
	}
	
	/**
	 * 2017/7/28增加
	 * 将不符合规则的内容转换成默认内容(适用于临时表)
	 * */
	private boolean tempDataIsAllow(Cell cell,int cellnum,int rownum) {
		
		boolean result = true;
		String cellValue =  getCellValue(cell);
		if (cellnum == 0 && cellValue != null && cellValue.length() > 0) {
			name = cellValue;
		}
		switch (cellnum) {
		case  2:
			if (checkTempTelIsExist(cellValue)){
				loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：电话号码已存在");
				result = false;
			}
			break;
		case  5:
			String arr1[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
			if (cellValue != null && !checkIsInArr(cellValue, arr1)){
				cell.setCellValue("1");
			} 
			break;
		/*case 8:
			if (cellValue.length() > )
			break;*/
		case  9:
			String arr2[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
			if (cellValue != null && !checkIsInArr(cellValue, arr2)){
				cell.setCellValue("0");
			} 
			break;
		case 10:
			String arr3[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
			if (cellValue != null && !checkIsInArr(cellValue, arr3)){
				cell.setCellValue("0");
			} 
			break;
		default:
			break;
		}
		return result;
	}

	
	/**
	 * 判断单元格中的内容是否合格，
	 * type:人或企业
	 * cellnum：第几个单元格
	 * cell：单元格内容
	 * rownum: 第几行
	 * */
	private  boolean dataIsAllow(Integer type,Cell cell,int cellnum,int rownum) {
		
		boolean result = true;
		String cellValue =  getCellValue(cell);
		//在这里获取企业和个人的名称
		//都是第0个单元格
		if (cellnum == 0 && cellValue != null && cellValue.length() > 0) {
			name = cellValue;
		}
		if (type == 0) {
			//按人才的判断
			//需要判断的：0姓名2：联系电话3：报考专业 5成熟等级 9客户来源 10客户分类
			switch (cellnum) {
			case 0:
			case 3: 
				//单元格不为空
				if (cellValue==null || cellValue.length() < 1) {
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格内容不能为空");
				}
				break;
			/*case 2:
				//先判断是否为空，再判断是否存在
				if (cellValue==null || cellValue.length() < 1) {
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格不能为空");
				} else {
					if (checkTelIsExist(cellValue)){
						result = false;
						loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：用户电话号码已存在");
					}
				}
				break; */
				
			case  5:
				String arr1[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
				if (!checkIsInArr(cellValue, arr1)){
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格数据输入错误");
				}
				break;
			case 8:
				//先判断是否为空，再判断是否存在
				if (cellValue==null || cellValue.length() < 1) {
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格不能为空");
				} else {
					if (checkIdcardIsExist(cellValue)){
						result = false;
						loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：身份证已存在");
					}
				}
				break; 	
			case  9:
				String arr2[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
				if (!checkIsInArr(cellValue, arr2)){
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格数据输入错误");
				}
				break;
			case 10:
				String arr3[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
				if (!checkIsInArr(cellValue, arr3)){
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格数据输入错误");
				}
				break;
			default:
				break;
			}
		} else {
			//按企业的判断
			//需要判断的0企业名称1唯一标识符2联系人3联系电话4证件用途6成熟等级7客户来源8客户来源
			switch (cellnum) {
			case 0:
				//先判断是否为空，再判断是否存在
				if (cellValue==null || cellValue.length() < 1) {
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格不能为空");
				} else {
					if (checkTrimIsExist(cellValue, 0)){
						result = false;
						loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：企业名已存在");
					}
				}
				break;
			case 1:
				//先判断是否为空，再判断是否存在
				if (cellValue==null || cellValue.length() < 1) {
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格不能为空");
				} else {
					if (checkTrimIsExist(cellValue, 1)){
						result = false;
						loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：唯一标识符已存在");
					}
				}
				break;
			case 2:
			case 3:
				if (cellValue==null || cellValue.length() < 1) {
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格不能为空");
				}
				break;
			case 4:
				String arr1[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
				if (!checkIsInArr(cellValue, arr1)){
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格数据输入错误");
				}
				break;
			case 6:
				String arr2[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
				if (!checkIsInArr(cellValue, arr2)){
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格数据输入错误");
				}
				break;
			case 7:
				String arr3[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
				if (!checkIsInArr(cellValue, arr3)){
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格数据输入错误");
				}
				break;
			case 8:
				String arr4[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12"};
				if (!checkIsInArr(cellValue, arr4)){
					result = false;
					loglist.add(name+":第"+(rownum+1)+"行导入失败，失败原因：第"+(cellnum+1)+"个单元格数据输入错误");
				}
				break;
			default:
				break;
			}
		}
		return result;
	}

	/**
	 * 判断用户电话号码是否已经存在
	 * */
	private  boolean checkTelIsExist(String tel){
		
		 
		boolean result = false;
		
		CustomerContacts cc = new CustomerContacts();
		cc.setTel(tel);
		int i = customerContactsService.gettelcount(cc);
		if (i > 0) {
			result = true;
		}
		return result;
	}
	/**
	 * 判断用户电话号码是否已经存在
	 * */
	private  boolean checkIdcardIsExist(String idcard){
		
		 
		boolean result = false;
		
		CustomerInfo info = new CustomerInfo();
		info.setIdcard(idcard);;
		int i = customerService.getIdCardCount(info);
		if (i > 0) {
			result = true;
		}
		return result;
	}
	
	
	
	/**
	 * 判断用户电话号码是否已经存在(临时表)
	 * */
	private  boolean checkTempTelIsExist(String tel){
		 
		boolean result = false;
		CustomerInfoTemp cit = new CustomerInfoTemp();
		cit.setTel(tel);
		int i = customerInfoTempService.checkTelIsExist(cit);
		if (i > 0) {
			result = true;
		}
		return result;
	}
	
	
	/**
	 * 判断企业名，企业唯一标识符是否已经存在
	 * type = 0 企业名
	 * type = 1 唯一标识符
	 * */
	private  boolean checkTrimIsExist(String name,int type){
		
		boolean result = false;
		CustomerInfo ci = new CustomerInfo();
		ci.setType(1);
		if (type == 0) {
			//企业名
			ci.setCname(name);
			ci.setFirm(null);
		} else if (type == 1) {
			//唯一标识符
			ci.setCname(null);
			ci.setFirm(name);
		}
		Integer resule = customerService.getCustomerInfoVerifyCount(ci);
		if (resule != null && resule > 0) {
			result = true;
		}
		return result;
	}

	/**
	 * 判断值是否在指定的数组中
	 * */
	private  boolean checkIsInArr(String i,String[] arr){
		boolean result = false;
		for (String s : arr) {
			if (s.equals(i)) {
				result = true;
			}
		}
		return result;
	}
	
	/**
	 * 将单元格内容存入info(基本)
	 * */
	private  CustomerInfo saveInfo(CustomerInfo info,int cellnum,String cellValue){
		
		if (info.getType() == 0) {
			//存入人才信息
			switch (cellnum) {
			case 0:
				info.setCname(cellValue);
				break;
			case 1:
				info.setNickname(cellValue);
				break;
			case 2:
				info.setTel(cellValue);
				break;
			case 3:
				info.setTechnicalpost(cellValue);
				break;
			case 4:
				info.setAddress(cellValue);
				break;
			case 5:
				info.setState(Integer.parseInt(cellValue));
				break;
			case 6:
				info.setQq(cellValue);
				break;
			case 7:
				info.setWebchart(cellValue);
				break;
			case 8:
				info.setIdcard(cellValue);
				break;
			case 9:
				info.setSource(Integer.parseInt(cellValue));
				break;
			case 10:
				info.setLevel(Integer.parseInt(cellValue));
				break;
			case 11:
				info.setSummary(cellValue);
				break;
			case 12:
				if(cellValue!=null) {
					info.setBoutique(Integer.parseInt(cellValue)) ;
				}
				break;
			default:
				break;
			}
		} else {
			//存入企业信息企业名称	唯一标识符	联系人	联系电话	证件用途	地址	成熟等级	客户来源	客户等级	资质等级	企业要求
			switch (cellnum) {
			case 0:
				info.setCname(cellValue);
				break;
			case 1:
				info.setFirm(cellValue);
				break;
			case 2:
				info.setName(cellValue);
				break;
			case 3:
				info.setTel(cellValue);
				break;
			case 4:
				info.setPaperspurpose(Integer.parseInt(cellValue));
				break;
			case 5:
				info.setAddress(cellValue);
				break;
			case 6:
				info.setState(Integer.parseInt(cellValue));
				break;
			case 7:
				info.setSource(Integer.parseInt(cellValue));
				break;
			case 8:
				info.setLevel(Integer.parseInt(cellValue));
				break;
			case 9:
				info.setZzleval(cellValue);
				break;
			case 10:
				info.setSummary(cellValue);
				break;
			case 11:
				if(cellValue!=null) {
					info.setBoutique(Integer.parseInt(cellValue)) ;
				}
				break;
			default:
				break;
			}
			
		}
		return info;
	}
	
	/**
	 * 将内容存入temp对象
	 * */
	private CustomerInfoTemp saveTempInfo(CustomerInfoTemp info,int cellnum,String cellValue){
		
		switch (cellnum) {
		case 0:
			info.setCname(cellValue);
			break;
		case 1:
			info.setNickname(cellValue);
			break;
		case 2:
			info.setTel(cellValue);
			break;
		case 3:
			info.setTechnicalpost(cellValue);
			break;
		case 4:
			info.setAddress(cellValue);
			break;
		case 5:
			if (cellValue != null && cellValue.length() > 0) {
				info.setState(Integer.parseInt(cellValue));
			}
			break;
		case 6:
			info.setQq(cellValue);
			break;
		case 7:
			info.setWebchart(cellValue);
			break;
		case 8:
			info.setIdcard(cellValue);
			break;
		case 9:
			if (cellValue != null && cellValue.length() > 0) {
				info.setSource(Integer.parseInt(cellValue));
			}
			break;
		case 10:
			if (cellValue != null && cellValue.length() > 0) {
				info.setLevel(Integer.parseInt(cellValue));
			}
			break;
		case 11:
			info.setSummary(cellValue);
			break;
		case 12:
			if(cellValue!=null) {
				info.setBoutique(Integer.parseInt(cellValue)) ;
			}
			break;
		default:
			break;
		}
		
		return info;
	}
	
	
	

}
